﻿$(function () {
    if (0 < $('a.lightbox').length) {
        function initVanillaLightBox() {
            $('a.lightbox').unbind('click').removeAttr('target');
            if (0 < $('a.lightbox').length) {
                if (600 <= $(window).width()) {
                    $('a.lightbox').vanillabox({
                        closeButton: true,
                        adjustToWindow: 'horizontal'
                    });
                } else {
                    $('a.lightbox').attr('target', '_blank');
                }
            }
        } initVanillaLightBox();

        function windowResizeActions() {
            initVanillaLightBox();
        }

        var resizeTimer;
        $(window).resize(function () {
            clearTimeout(resizeTimer);
            resizeTimer = setTimeout(windowResizeActions, 100);
        });
    }
});